package ACWing.mathematicalknowledge.欧几里得;
//877. 扩展欧几里得算法

import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2023/1/12 17:12
 */
public class ExtendEuclideanAlgorithm {
    static int x,y;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        while (n-->0){
            int a=sc.nextInt();
            int b=sc.nextInt();
            int d=gcd(a,b);
            System.out.println(x+" "+y);

        }
    }
    public static int gcd(int a,int b){
        if(b==0){
            x=1;y=0;

            return a;
        }
        int d= gcd(b,a%b);

        int tmp = x;
        x = y;
        y = tmp - a / b * y;
        return d;
    }
}
